package com.tiger.distributelock.config;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class ZooKeeperWatcher implements Watcher {
    private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperWatcher.class);

    @Override
    public void process(WatchedEvent watchedEvent) {
        Event.EventType type = watchedEvent.getType();
        switch (type) {
            case NodeCreated:
                LOG.info("create node");
                break;
            case NodeDataChanged:
                LOG.info("node data changed");
                break;
            case NodeDeleted:
                LOG.info("node deleted");
                break;
            case NodeChildrenChanged:
                LOG.info("node children changed");
                break;
        }
    }
}
